package com.devunion.salon.web.bean;

import com.devunion.salon.persistence.Payment;
import org.apache.commons.lang.StringUtils;

/**
 * @author Timoshenko Alexander 14.09.2008 : 19:06:18
 */
public class PaymentBean {
    private Long id;
    private String method;
    private Float amount;

    public PaymentBean() {
    }

    public PaymentBean(Payment payment) {
        this.method = payment.getMethod();
        this.amount = payment.getValue();
        this.id = payment.getId();
    }

    public String getMethod() {
        if(StringUtils.isBlank(method)){
            return method;
        }
        return method.toLowerCase();
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public Float getAmount() {
        return amount;
    }

    public void setAmount(Float amount) {
        this.amount = amount;
    }

    public Long getId() {
        return id;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        PaymentBean that = (PaymentBean) o;

        if (method != null ? !method.equals(that.method) : that.method != null) return false;

        return true;
    }

    public int hashCode() {
        return (method != null ? method.hashCode() : 0);
    }
}
